/**
 * Created by 97203 on 2018/06/08.
 */
$(function () {
    var dept_datagrid = $("#dept_datagrid");
    var dept_dialog = $("#dept_dialog");
    var dept_form = $("#dept_form");
    var item_dialog = $("#item_dialog")
    var item_form = $("#item_form")
    dept_datagrid.datagrid({
        url: '/clientClaim/query.do',
        fitColumns: true,
        fit: true,
        pagination: true,    //分页条
        rownumbers: true,     //行号列
        singleSelect: true,
        toolbar: '#tb',
        columns: [[
            {
                field: 'claim', title: '报案人', width: 100, formatter: function (value,row) {
                return row.claim ? row.claim.reporter : "";
            }},
            {
             field: 'claim1', title: '联系电话', width: 100, formatter: function (value,row) {
             return row.claim ? row.claim.tel : "";
             }},
            {
                field: 'claim2', title: '保单编号', width: 100, formatter: function (value,row) {
                return row.claim ? row.claim.staging : "";
            }},
            {
                field: 'claimitem', title: '车牌号码', width: 100, formatter: function (value,row) {
                return row.claimitem ? row.claimitem.carnumber : "";
            }},
            {
                field: 'claimitem1', title: '事故详情', width: 100, formatter: function (value,row) {
                return row.claimitem ? row.claimitem.particulars : "";
            }},
            {
                field: 'damage', title: '理赔收款人', width: 100, formatter: function (value,row) {
                return row.damage ? row.damage.payee : "";
            }},
            {
                field: 'damage1', title: '理赔金额', width: 100, formatter: function (value,row) {
                return row.damage ? row.damage.money : "";
            }},
            {
                field: 'damage2', title: '拨款卡号', width: 100, formatter: function (value,row) {
                return row.damage ? row.damage.carnumber : "";
            }},
            {
                field: 'damage3', title: '拨款时间', width: 100, formatter: function (value,row) {
                return row.damage ? row.damage.disposeTime : "";
            }}

        ]]
    })



    var methodObj = {
        reload: function () {
            dept_datagrid.datagrid('reload');
        },
        exportXls: function () {
            var keyword = $("[name=keyword]").val();
            window.location.href = "/clientClaim/exportXls.do?keyword=" + keyword ;
        },
        query: function () {
            var keyword = $("[name=keyword]").val();
            dept_datagrid.datagrid('load', {
                keyword: keyword
            })
        },
    }

    $("a[data-cmd]").click(function () {
        //获取按钮上的data-cmd的值
        var methodName = $(this).data("cmd");
        methodObj[methodName]();
    })

})
